<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*,java.sql.*,java.text.*, dbAccess.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List of Patients</title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
<script type="text/javascript">
function changeNumberofDays(code)
{
	var mylist;
	if (code == "1")
	{
		mylist = document.forms["frmSearchByRange"].cmbStartMonth;
	}
	else
	{
		mylist = document.forms["frmSearchByRange"].cmbEndMonth;
	}
	var month = mylist.selectedIndex;
	if ((month == 0) || (month == 2) || (month == 4) || (month == 6) || (month == 7) || (month == 9) || (month == 11))
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 31; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else if (month == 1)
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 28; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 30; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
}
</script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="178" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="616" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL </h1></td>
    <td width="231" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="180" height="119" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
    <td height="19" colspan="2" valign="top">Welcome <%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>
  	<td><a href="home.jsp" title="Logout">Logout</a></td>
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  
 <tr>
    <td valign="top" class="style2"><p align="center"><strong>Quicklinks</strong></p>
    <p><a href="patientListforAdmin.jsp">View List of Patients</a></p>
    <p><a href="editAdmin.jsp">Change My Personal Information</a></p>
    <p><a href="http://www.webmd.com">WebMD</a></p>
	<p><a href="adminHome.jsp">Back to Homepage </a></p>
	</td>
	
    <td rowspan="2" valign="top"><strong>List of Patients</strong>
    <table width=100% border="1" align="left">
      <thead>
        <tr>
          <td><div align="center"><strong>Patient Id</strong></div></td>
          <td><div align="center"><strong>Patient First Name</strong></div></td>
           <td><div align="center"><strong>Patient Last Name</strong></div></td>
          <td><div align="center"><strong>Gender</strong></div></td>
          <td><div align="center"><strong>Phone Number</strong></div></td>
          <td><div align="center"><strong>Email Address</strong></div></td>
          <td><div align="center"><strong>Current Health</strong></div></td>
          <td><div align="center"><strong>Health Card</strong></div></td>
          <td><div align="center"><strong>Password</strong></div></td>
          
        </tr>
        </thead>
        <tbody>
        <%
        
        Login lgn = new Login();
		ResultSet rs;
		int patientId = 0;
		String patientFirstName = "unknown";
		String patientLastName = "unknown";
		String gender = "unknown";
		String phone = "unknown";
		String emailAddress = "unknown";
		String healthCard = "unknown";
		String homeAddress = "unknown";
		String password = "unknown";
		String currHealth = "unknown";
		
		DbAccess access = new DbAccess();
		String query = "select * from tbl_patient where IsDeleted = 0";
			
		
		rs = access.ExecuteSelect(access.connect(), query);;
		if (rs != null)
		{
			while (rs.next())
			{
				patientId = rs.getInt("tbl_patient.PatientId");
				patientFirstName = rs.getString("tbl_patient.FirstName");
				patientLastName = rs.getString("tbl_patient.LastName");
				gender = rs.getString("tbl_patient.Gender");
				phone = rs.getString("tbl_patient.Phone");
				emailAddress = rs.getString("tbl_patient.EmailAddress");
				currHealth = rs.getString("tbl_patient.CurrentHealth");
				homeAddress= rs.getString("tbl_patient.healthCard");
        		password = rs.getString("tbl_patient.Password");
        	%>
        		<tr>
        			<td>
        				<%=patientId%>
        			</td>
        			<td>
        				<%=patientFirstName%>
        			</td>
        			<td>
        				<%=patientLastName%>
        			</td>
        			<td>
        				<%=gender%>
        			</td>
        			<td>
        				<%=phone%>
        			</td>
        			<td>
        				<%=emailAddress%>
        			</td>
        			<td>
        				<%=currHealth%>
        			</td>
        			<td>
        				<%=healthCard%>
        			</td>
        			<td>
        				<%=password%>
        			</td>
        			
        		</tr>
        	<%
			}
		}
        %>
        </tbody>
      </table>      
 

</body>
</html>